package com.magicode.cms.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.magicode.cms.common.assist.json.JsonOperation;
import com.magicode.cms.dao.IRepresentWorksDao;
import com.magicode.cms.dao.impl.RepresentWorksDaoImpl;
import com.magicode.cms.entiy.base.RepresentWorks;
import com.magicode.cms.service.IRepresentWorksService;
@Service("serviceRepresentWorks")
public class RepresentWorksServiceImpl extends BaseServiceImpl<RepresentWorks, IRepresentWorksDao> implements
		IRepresentWorksService {
	@Autowired
	@Qualifier("daorepresentworks")
	public IRepresentWorksDao representWorksDaoImpl;
	
	public IRepresentWorksDao getRepresentWorksDaoImpl() {
		return representWorksDaoImpl;
	}

	public void setRepresentWorksDaoImpl(IRepresentWorksDao representWorksDaoImpl) {
		this.representWorksDaoImpl = representWorksDaoImpl;
	}

	@Override
	public List<Map<String, Object>> getBeanInfo() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getHql(Map<String, String> map) throws Exception {
		String hql ="from " +RepresentWorks.class.getName()+" "+entity_alias_name+" ";

		if(null!=map && !map.isEmpty()){
			hql += "where 1 = 1  ";  //and "+entity_alias_name+".isContribute = 0
			if(map.containsKey(field_id)){
				hql = hql+" and "+entity_alias_name+".id = '"+map.get(field_id)+"'";
			}
			if(map.containsKey("title")){
				hql = hql+" and "+entity_alias_name+".title like '%"+map.get("title")+"%'";
			}
			if(map.containsKey("year")){
				hql = hql+" and "+entity_alias_name+".status = '"+map.get("status")+"'";
			}
		}
		return hql;
	}

	@Override
	public List<Map<String, Object>> grid(Map<String, String> querywhere) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public IRepresentWorksDao getDao() throws Exception {
		// TODO Auto-generated method stub
		return representWorksDaoImpl;
	}

}
